package com.example.demo;

import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

class Message{
    private String from;
    private String to;
    private String message;

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public String getTo() {
        return to;
    }

    public void setTo(String to) {
        this.to = to;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
@RestController
@RequestMapping("/message")
public class HelloSevert3 {
    List<Message> list = new ArrayList<>();
    @RequestMapping("/publish")
    public boolean publish(Message message){
         if(!StringUtils.hasLength(message.getMessage())||!StringUtils.hasLength(message.getFrom())||!StringUtils.hasLength(message.getTo())){
             return false;
         }
         list.add(message);
         return true;
    }
    @RequestMapping("getMessage")
public  List<Message> getLish(){
        return list;
}
}
